import { Modal } from "antd";
import DynamicQueryTable, { SelectionType } from "@/components/report/DynamicQueryTable";
import { useState } from "react";
import type { QmsIndex } from "@/pages/qms/index/entity";

interface MultiQcIndexSelectProps {
	open: boolean;
	onCancel: () => void;
	onOk: (selectedQcIndexes: QmsIndex[]) => void;
}

const MultiQcIndexSelect:React.FC<MultiQcIndexSelectProps> = ({ open, onCancel, onOk }) => {
  
  // 选中的检测项
  const [selectedQcIndexes, setSelectedQcIndexes] = useState<QmsIndex[]>([]);

  const handleOk = () => {
		onOk(selectedQcIndexes);
	};

	return (
		<Modal title="选择检测项" open={open} onCancel={onCancel} onOk={handleOk} width={800} destroyOnClose>
			<DynamicQueryTable 
        reportCode="qms_index_select" 
        selectionType={SelectionType.CHECKBOX}
        onSelectChange={(selectedRows) => {setSelectedQcIndexes(selectedRows)}}  
      />
		</Modal>
	);
}

export default MultiQcIndexSelect;